package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;


/**
 * Write a description of class RenrCtr here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class RentCtr
{
    // instance variables - replace the example below with your own
    private RentCollection rentCollection;
    private AddressCtr addressCtr;
    private DVDCtr dvdCtr;

    /**
     * Constructor for objects of class RenrCtr
     */
    public RentCtr()
    {
        // initialise instance variables
        rentCollection = RentCollection.getInstance();
        addressCtr = new AddressCtr();
        dvdCtr = new DVDCtr();
    }
 
    public DVDCtr getDvdCtr()
    {
        return dvdCtr;
    }
    
    public void createRent(long id, long pid, long did, int rentDate, int dueDate, boolean status, int returnDate)
    {
        Person p = addressCtr.getPerson(pid);
        DVD d = dvdCtr.getDVD(did);
        Copy c = d.getFirstCopy();
        
        Rent r = new Rent(id, p, c, rentDate, dueDate, status, returnDate);
        
        rentCollection.addRent(r);
    }
    
   public void updateRent(long id, boolean status, int returnDate)
   {
       rentCollection.updateRent(id, status, returnDate);
   }
   
   public void updateRent(long id, int dueDate)
   {
       rentCollection.updateRent(id, dueDate);
   }
   
   public void deleteRent(long id)
   {
       rentCollection.deleteRent(id);
   }
   
   public ArrayList<Rent> getPersonalRent(long id)
   {
       ArrayList<Rent> allRents = new ArrayList<Rent>(); 
       
       allRents = rentCollection.getPersonalRent(id);
       return allRents;
   }
    
   public Rent getRent(long id)
   {
       Rent r = rentCollection.getRent(id);
       return r;
    }
}
